package cn.fl.system.service.impl;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cmm.mid.core.framework.page.Pager;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.fl.system.dto.SysScoreRecDTO;
import cn.fl.system.service.ISysScoreApiService;
import cn.fl.system.service.ISysScoreRecService;
import cn.fl.system.transform.SysScoreRecVOTransform;
import cn.fl.system.vo.SysScoreRecVO;

/**
 * @Description: 评分记录表 客户端服务层接口实现
 */
@Service
public class SysScoreRecServiceImpl implements ISysScoreRecService {

	/**
	 * 日志
	 */
	@SuppressWarnings("unused")
	private static final Logger logger = LoggerFactory.getLogger(SysScoreRecServiceImpl.class);
	
	/**
	 * 系统评分模版 API服务
	 */
	@Autowired
	private ISysScoreApiService sysScoreApiService;

	@Override
	public SysScoreRecVO selectById(Long id) throws BaseException{
		if(StringUtils.isEmpty(id))return null;
		//TODO 业务逻辑
		SysScoreRecDTO dto = null;//this.自定义ApiService.selectById(id);
		return SysScoreRecVOTransform.toVO(dto);
	}

	@Override
	public Long add(SysScoreRecVO entity) throws BaseException{
		if(null == entity)return null;
		//新增要把子信息一同加上,调用接口处要处理处理
		return null; // this.sysScoreApiService.add(SysScoreRecVOTransform.toDTO(entity));
	}

	@Override
	public boolean removeById(Long id) throws BaseException{
		if(StringUtils.isEmpty(id))return false;
		//return this.sysScoreRecApiService.removeById(id);
		//TODO 业务逻辑
		return false;
	}

	@Override
	public boolean modify(SysScoreRecVO entity) throws BaseException{
		if(null == entity)return false;
		return false;// this.sysScoreApiService.modifySysScoreRec(SysScoreRecVOTransform.toDTO(entity));
	}

	@Override
	public Pager searchListPage(Pager page) throws BaseException{
		if(null == page)page = new Pager();
		/*SysScoreRecQueryCondition sysScoreRecQueryCondition = new SysScoreRecQueryCondition();
		sysScoreRecQueryCondition.setPkId(100L);
		List<SysScoreRecDTO> sysScoreRecDTOList = this.sysScoreApiService.searchSysScoreRecList(sysScoreRecQueryCondition);
		page.setResultList(SysScoreRecVOTransform.toVOList(sysScoreRecDTOList));*/
		return page;
	}

	@Override
	public boolean removeById(List<Long> ids) throws BaseException {
		if(CollectionUtils.isEmpty(ids))return false;
		return false;// this.sysScoreApiService.removeSysScoreRec(ids);
	}
	
public int getScore(String id,Object o){
		  
	
		
		
		
		
		return 1;  
	}
	  
    public static String getClassname(Object o) throws Exception {
    	
    	return o.getClass().getSimpleName();
    }
    
    public static Object invokeMethod(Object o, String methodName) throws Exception {   
        
        Class ownerClass = o.getClass();   
        Method[] ms=ownerClass.getMethods();
        Method method;
      //  Class[] argsClass = new Class[args.length];   
       int j=0;
        for (int i = 0;i<ms.length; i++) {   
          String methodnm=ms[i].getName();
          if(methodnm.toLowerCase().equals(methodName.toLowerCase())){  
        	 j=i;
          }
        }   

        return ms[j].invoke(o);   
   }

	@Override
	public List<SysScoreRecVO> selectPrjScore(Long id) throws BaseException {
		// TODO Auto-generated method stub
		return SysScoreRecVOTransform.toVOList(this.sysScoreApiService.selectPrjScore(id));
	}
	@Override
	public List<SysScoreRecVO> getScoreByPrjId(Long id) throws BaseException{
		List<SysScoreRecVO> listVo = new ArrayList<SysScoreRecVO>();
		if(StringUtils.isNotEmpty(id)){
			listVo = SysScoreRecVOTransform.toVOList(this.sysScoreApiService.getPrjScoreByPrjId(id));
		}
		return listVo;
	}


    
}
